//package org.ejb.stateless;
//
//import java.util.Date;
//import java.util.List;
//import java.util.logging.Logger;
//
//import javax.ejb.Stateless;
//import javax.ejb.TransactionAttribute;
//import javax.ejb.TransactionAttributeType;
//import javax.persistence.EntityManager;
//import javax.persistence.PersistenceContext;
//import javax.persistence.Query;
//
//import org.ejb.api.ILocationStatelessRemote;
//import org.ejb.entities.Location;
//import org.ejb.entities.Produit;
//import org.ejb.entities.Utilisateur;
//import org.ejb.entities.ValidationException;
//
//@SuppressWarnings(value = "unchecked")
//@TransactionAttribute(value = TransactionAttributeType.REQUIRED)
//@Stateless(mappedName = "org.ejb.stateless.LocationStateless@Remote", description = "Location stateless", name = "LocationStateless")
//public class LocationStateless implements ILocationStatelessRemote {
//	@PersistenceContext
//    private EntityManager em;
//
//    private final String cname = this.getClass().getName();
//    private Logger logger = Logger.getLogger("org.ejb.stateless");
//    
//    public Location createLocation(final Location location, final Date datePret, final Double montant,final Produit product,final Utilisateur utilisateur) {
//        final String mname = "createLocation";
//        logger.entering(cname, mname, location);
//
//        // On s'assure de la validite des paramatres
//        if (location == null)
//            throw new ValidationException("Location object is null");
//
//        location.setDatePret(datePret);
//        location.setMontant(montant);
//        location.setProduct(product);
//        location.setUtilisateur(utilisateur);
//
//        // On modifie l'objet de la base de donnees
//        em.merge(location);
//
//        logger.exiting(cname, mname, location);
//        return location;
//    }
//    
//    public Location findLocation(final Long locationId) {
//        final String mname = "findLocation";
//        logger.entering(cname, mname, locationId);
//
//        // On s'assure de la validite des paramatres
//        if (locationId == null)
//            throw new ValidationException("Invalid id");
//
//        Location loc;
//
//        // On recherche l'objet a partir de son identifiant
//        loc = em.find(Location.class, locationId);
//
//        logger.exiting(cname, mname, loc);
//        return loc;
//    }
//
//    public void deleteLocation(final Location location) {
//        final String mname = "deleteLocation";
//        logger.entering(cname, mname, location);
//
//        // On s'assure de la validite des paramatres
//        if (location == null)
//            throw new ValidationException("Location object is null");
//
//        // On supprime l'objet de la base de donnees
//        em.remove(em.merge(location));
//
//        logger.exiting(cname, mname);
//    }
//
//    public Location updateLocation(final Location location, final Date datePret, final Double montant,final Produit product,final Utilisateur utilisateur) {
//        final String mname = "updateLocation";
//        logger.entering(cname, mname, location);
//
//        // On s'assure de la validite des paramatres
//        if (location == null)
//            throw new ValidationException("Location object is null");
//
//        location.setDatePret(datePret);
//        location.setMontant(montant);
//        location.setProduct(product);
//        location.setUtilisateur(utilisateur);
//
//        // On modifie l'objet de la base de donnees
//        em.merge(location);
//
//        logger.exiting(cname, mname, location);
//        return location;
//    }
//
//    public List<Location> findLocations() {
//        final String mname = "findLocations";
//        logger.entering(cname, mname);
//
//        Query query;
//        List<Location> locations;
//
//        // On modifie l'objet de la base de donnees
//        query = em.createQuery("SELECT c FROM Location c");
//        locations = query.getResultList();
//
//        logger.exiting(cname, mname, locations.size());
//        return locations;
//    }
//}
